using System;
using UnityEngine;
using System.Collections.Generic;
namespace flash.display
{
	public class DisplayObjectContainer:InteractiveObject
	{
		public DisplayObjectContainer():base()
		{

		}
		protected List<DisplayObject> children = new List<DisplayObject>();
		public int numChildren{get{return children.Count;}}
		public virtual void addChild(DisplayObject child)
		{
			child.SetParent(this);
			children.Add(child);
		}
		
		protected override void OnAdded()
		{
			foreach(DisplayObject child in children)
			{
				child.SetStage(stage);//设置子元件的stage
			}
			base.OnAdded();
		}
		public override void Render()
		{
			if(stage != null)
			{
				foreach(DisplayObject child in children)
				{
					child.Render();
				}
			}
			base.Render();
		}
		protected override void RenderAlpha()
		{
			base.RenderAlpha();
			//如果子元件也设置透明度的话就开启这玩意
//			foreach(DisplayObject child in children)
//			{
//				child.alpha = alpha;
//				child.Render();
//			}
		}
	}
}

